package com.itheima;

import com.itheima.dao.BookDao;
import com.itheima.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author: dh
 * @date: 2023-10-26 15:00
 * 注解开发定义Bean。
 */
public class App {

    public static void main(String[] args) {

        // 1.获得IoC容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 2.通过getBean方法来获得对象
        BookDao bookDao = (BookDao) ctx.getBean("bookDao");
        // 3.打印对象
        System.out.println(bookDao);
        BookService bookService = ctx.getBean(BookService.class);
        bookService.save();
        System.out.println(bookService);
    }
}
